#include "BeginInterface.h"
#include "GameButton.h"
#include "../data/GameInfo.h"

void BeginInterface::Init()
{
    auto &info = GameInfo::Instance();
    beginButton.position = {info.windowWidth / 2, info.windowHeight / 2};
    beginButton.texWidth = 340;
    beginButton.texHeight = 110;
    beginButton.width = 300;
    beginButton.height = 80;
    beginButton.onClick = [] {
        GAME_PAUSE_MARK = false;
        GAME_MUSIC.Play(GAME_INFO.musicPool[MusicId::MUSIC_HEISHENHUABACKGROUND]);
    };
    beginButton.texNormal = GameInfo::Instance().texturePool[TexId::TEX_BUTTON_BEGIN_NORMAL];
    beginButton.texHover = GameInfo::Instance().texturePool[TexId::TEX_BUTTON_BEGIN_HOVER];
    beginButton.texDisable = GameInfo::Instance().texturePool[TexId::TEX_BUTTON_BEGIN_DISABLED];
    beginGroundTex = GameInfo::Instance().texturePool[TexId::TEX_BEGIN_INTERFACE];
}


void BeginInterface::OnInput(SDL_Event &event)
{
    beginButton.OnInput(event);
}

void BeginInterface::OnUpdate()
{

}

void BeginInterface::OnRender()
{
    SDL_RenderCopy(GAME_RENDERER, beginGroundTex, nullptr, nullptr);
    beginButton.Render(GAME_RENDERER, GameInfo::Instance().font,  {0, 0, 0}, "开始游戏");
}
